<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*, java.util.*"%>
<%@ page import="semiProject_army.mvc.beans.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="userid" value="${ sessionScope.userId }"/>
<article>

	<div id="freetitle">
						<img src="img/freetitle.jpg"></a>
	</div>
	<div class="freeform">
		<div class="freeTitle">${boardtitle }</div>
		
			<form name="searchForm" action="search.mvc" method="post">
				<div class="searchForm">
					<input id="searchipt" type="text" name="word">
					<button type="submit" class="btn btn-info" id="searchbtn">검색</button> 
				</div>
			</form>
		
		<table class="freelistTable">

			
			<tr>
				<th class="listThNo">번 호</th>
				<th class="listThTitle">글제목</th>
				<th class="listThWriter">작성자</th>
				<th class="listThDate">작성일</th>
				<th class="listThCount">조회수</th>
			</tr>

			<c:if test="${ fbCount <= 0 }">
				<tr>
					<td class="listTdSpan" colspan="4">게시글이 존재하지 않습니다.</td>
				</tr>
			</c:if>

			<c:if test="${ fbCount > 0 }">

				<c:forEach var="board" items="${ fbList }">
					<tr>
						<td class="listTdNo">${ board.no }</td>
						<td class="listTdTitle">
							<c:if test="${ board.title.length() > 30 }">
								<a href="view.mvc?no=${ board.no }&pageNum=${ currentPage }">
									${ board.title.substring(0, 30) }...</a>
							</c:if> 
							<c:if test="${ board.title.length() <= 30 }">
								<a href="view.mvc?no=${ board.no }&pageNum=${ currentPage }">
									${ board.title }</a>
							</c:if>
						<td class="listTdWriter">${ board.writer }</td>
						<td class="listTdDate"><fmt:formatDate
								value="${ board.regDate }" pattern="yyyy-MM-dd" /></td>
						<td class="listTdCount">${ board.readCount }</td>
					</tr>
				</c:forEach>
				<c:if test="${ (userid eq 'ADMIN') }">
				<tr>
				<td class="listWrite" colspan="5">
				<a href="write.mvc?pageNum=${ currentPage }">
						<img src="img/write.gif"></a></td>
			</tr>
			</c:if>
			
			<c:if test="${ (userid ne 'ADMIN') and (userid ne null) and ((boardtitle eq '자유게시판') or (boardtitle eq '교육마당') or (boardtitle eq '문화마당')) }">
				<tr>
				<td class="listWrite" colspan="5">
				<a href="write.mvc?pageNum=${ currentPage }">
						<img src="img/write.gif"></a></td>
			</tr>
			</c:if>
			
				<tr>
					<td colspan="5" class="listPage"><c:if
							test="${ startPage > PAGE_GROUP }">
							<a href="list.mvc?pageNum=${ startPage - PAGE_GROUP }">[이전]</a>
						</c:if> <c:forEach var="i" begin="${ startPage }" end="${ endPage }">
							<c:if test="${ i == currentPage }">
					[${ i }]
				</c:if>
							<c:if test="${ i != currentPage }">
								<a href="list.mvc?pageNum=${ i }">[${ i }]</a>
							</c:if>
						</c:forEach> <c:if test="${ endPage < pageCount }">
							<a href="list.mvc?pageNum=${ startPage + PAGE_GROUP }">[다음]</a>
						</c:if></td>
				</tr>
			</c:if>
		</table>
	</div>
</article>